import {createPinia} from 'pinia'
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate'
import global from './modules/global'
import user from './modules/user'
import player from './modules/player'
import type {UserStore, Store} from '@/store/types'

export const pinia = createPinia()
pinia.use(piniaPluginPersistedstate)
export const useStore = (): Store => {
    return {
        // 直接在此将pinia传递给仓库，在外部使用时会导致持久化失效
        globalStore: global(),
        userStore: user() as UserStore,
        playerStore: player()
    }
}
